package emergency;

import movement.Location;
import dispatch.DispatchCenter;

/**
 * A class for creating a new PublicDisturbance
 */
public class PublicDisturbance extends Emergency {

	/**
	 * Variable registering the amount of people injured in this
	 * PublicDisturbance
	 */
	private int numberofPeople;

	/**
	 * Initialize this new PublicDisturbance
	 * 
	 * @param location
	 *            The location of this PublicDisturbance
	 * 
	 * @param severity
	 *            The severity of this PublicDisturbance
	 * 
	 * @param dispatchCenter
	 *            The dispatchCenter where this publicDisturbance has to be
	 *            added to
	 * 
	 * @param numberOfPeople
	 *            The amount of people involved in this publicdisturbance
	 * 
	 * @post The location of this PublicDisturbance is set to the given location
	 * 
	 * @post The severity of this PublicDisturbance is set to the given severity
	 * 
	 * @post The amount of people involved in this PublicDisturbance is set to
	 *       the given amount
	 * 
	 * @post The dispatchCenter of this PublicDisturbance is set to the given
	 *       dispatchCenter
	 *       
	 * @post This publicdisturbance is added to the given dispatchcenter
	 */
	public PublicDisturbance(Location location, Severity severity,
			DispatchCenter dispatchCenter, int numberOfPeople) {
		super(location, severity, dispatchCenter, new EmergencyPolicyDefault());
		setNumberOfPeople(numberOfPeople);
	}

	/**
	 * Getter for getting the amount of people involved in this
	 * PublicDisturbance
	 * 
	 * @return Returns the amount of people involved in this PublicDisturbance
	 */
	public int getNumberOfPeople() {
		return numberofPeople;
	}

	/**
	 * Method for setting this PublicDisturbance his amount of involved people
	 * 
	 * @param numberofPeople
	 *            The amount of involved people in this PublicDisturbance
	 * 
	 * @post The amount of people involved is set to the given amount
	 */
	private void setNumberOfPeople(int numberofPeople) {
		if (numberofPeople >= 0)
			this.numberofPeople = numberofPeople;
		else
			throw new IllegalArgumentException("Amount cannot be negative");
	}

	/**
	 * Method for creating an description of this PublicDisturbance
	 * 
	 * @return Returns the description of this PublicDisturbance
	 */
	@Override
	public String toString() {
		String output = "severity is " + getSeverity().toString() + "  =  ";
		output += "PUBLIC DISTURBANCE ";
		if (numberofPeople > 0) {
			output += numberofPeople + "ppl involved";
		}
		return output;
	}

}
